{* $Id$ *}
{include_core file="admin/lib/header.html" title="短信记录列表"}
{if empty($search_filter) && empty($aliysms_list) && $status != 0 && 1 != 1}
  <div class="search-none search-none-bg">
    <p>没有记录！</p>
  </div>
{else}
  <div class="page-header border-bottom clearfix">
    <h2 class="left">短信管理<span>在这里对短信进行管理</span></h2>
  </div>
  <div class="search-level1 clearfix">
    <form action="aliysms/admin" method="get">
      <input type="hidden" name="is_advenced" value="0">
      <input type="hidden" name="status" value="{$status}">
      <input type="hidden" name="res_name" value="{$res_name}">
      <input {if $is_advenced == 1}style="display:none;"{/if} type="text" class="left" name="search_filter[mobile]" placeholder="请输入手机号" value="{$search_filter.mobile}">
      <button {if $is_advenced == 1}style="display:none;"{/if} type="submit" class="btn btn-success btn-sm left">搜索</button>
      <a href="javascript:void(0);" class="close js_advanced {if $is_advenced == 1}js_isOpen open{/if}">高级搜索<em></em></a>
    </form>
  </div>
  <div class="search-form js_advancedForm" {if $is_advenced == 0}style="display:none;"{/if}>
    <form action="aliysms/admin" method="get" class="js_aliysmsSearchForm">
      <input type="hidden" name="is_advenced" value="1">
      <input type="hidden" name="status" value="{$status}">
      <p>
        <label for="" class="search-f-label">手机号：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[mobile]" value="{$search_filter.mobile}">
      </p>
      <p>
        <label for="" class="search-f-label">模板内容：</label>
        <input type="text" class="search-f-ipt1" name="search_filter[content]" value="{$search_filter.content}">
      </p>
      <p>
      <label for="" class="search-f-label">添加时间：</label>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[start_date]" value="{$search_filter.start_date}" id="startDate">
        <span class="search-f-line"></span>
        <input type="text" class="search-f-ipt1 search-f-ipt2" name="search_filter[end_date]" value="{$search_filter.end_date}" id="stopDate">
      </p>
      <p><label for="" class="search-f-label"></label><button type="submit" class="btn btn-success btn-xs js_searchBtn">搜索</button></p>
    </form>
  </div>
  <!--start:列表-->
  <table class="list-table">
    <caption>按状态：
      <a href='{AnUrl("aliysms/admin?status=0")}' {if $status == 0} class="label label-primary" {else} class="label label-default" {/if}>全部</a>
      <a href='{AnUrl("aliysms/admin?status=5")}' {if $status == 5 || $status == 10} class="label label-primary" {else} class="label label-default" {/if}>发送成功</a>
      <a href='{AnUrl("aliysms/admin?status=1")}' {if $status == 1} class="label label-primary" {else} class="label label-default" {/if}>发送失败</a>
    </caption>
    <thead><tr>
      <th>手机号</th>
      <th>消息类型</th>
      <th>对应模板</th>
      <th>数据</th>
      <th>发送条数</th>
      <th>发送状态</th>
      <th style="width:130px;">发送时间</th>
      <!-- <th style="width:130px;">操作</th> -->
    </tr></thead>
    <tbody>
      {foreach $aliysms_list as $k=>$v}
        <tr id="dataList{$v.id}" {if $k%2 == 1} class="bg-gray"{/if} data-id="{$v.id}">
          <td>
            {$v.mobile}          
          </td>
          <td>{$v.type}</td>
          <td>{if $sms_code_list[$v.type]['sms_template']}{$sms_code_list[$v.type]['sms_template']}{else}系统模板{/if}</td>
          <td>
			{if $v.content}
			  {foreach $v.content as $key=>$val}
			  {$key}:{$val}<br/>
			  {/foreach}
			{/if}
		  </td>
          <td>{$v.send_sum}</td>
          
          <td>
            {if $v.status == 1}
            <button class="btn btn-danger btn-sm">发送失败</button>
            {elseif $v.status >= 5}
            <button class="btn btn-success btn-sm">发送成功</button>
            {/if}
          </td>
          <td>{time_format($v.add_time)}</td>
          <!--<td>
             
              <a href="{AnUrl("aliysms/admin/edit?id={$v.id}")}" class="btn btn-info btn-xs"><i class="icon-edit icon-white"></i>编辑</a>
              <a href="{AnUrl("aliysms/admin/delete?id={$v.id}")}" class="btn btn-danger btn-xs deleteOne"><i class="icon-trash icon-white"></i>删除</a>

              <a href="{AnUrl("aliysms/admin/change_status?id={$v.id}")}" class="btn btn-success btn-xs"><i class="icon-trash icon-white"></i>恢复</a>
            
          </td>-->
        </tr>
      {foreachelse}
          <tr><td class="txtleft" colspan="6">暂无数据</td></tr>
      {/foreach}
    </tbody>
  </table>
  {include_core file="admin/lib/pager.html"}
{/if}
<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
<script>
var resName = 'aliysms';
var jsaliysmsId = "{$search_filter.aliysms_id}";
$('.js_aliysmsId').load(siteUrl+'/aliysms/load_aliysms_option?res_name='+resName,function(){
  $('.js_aliysmsId').find('option').each(function(){
    if ($(this).attr('value') == jsaliysmsId) {
      $(this).attr('selected','selected');
    }
  });
});
$(function(){
  // 高级搜索
  $('.js_advanced').click(function(e){
    e.preventDefault();
    var thisObj = $(this);
    var outBox  = thisObj.closest('form');
    if (thisObj.hasClass('js_isOpen')) {
      thisObj.removeClass('js_isOpen open');
      outBox.find('input').show();
      outBox.find('button').show();
      $('.js_advancedForm').hide();
    } else {
      thisObj.addClass('js_isOpen open');
      outBox.find('input').hide();
      outBox.find('button').hide();
      $('.js_advancedForm').show();
    }
  });
  
  // 高级搜索时间验证
  $('.js_searchBtn').click(function(e){
    e.preventDefault();
    var thisObj   = $(this);
    var startDate = $.trim($('#startDate').val());
    var stopDate  = $.trim($('#stopDate').val());
    if (startDate > stopDate) {
      showMsg('结束时间应大于等于开始时间');
      return;
    }
    thisObj.closest('form').submit();
  });

  
  
});
</script>
{include_core file="admin/lib/footer.html"}